/**
 * 高级图文 / advancedNews
 * 只用于自定义菜单和关键词回复,不能用于群发
 * @authors 杨兴洲（of2502）
 * @date    2017/5/16 0016 11:04
 * @version 1.0
 */

import {model, Schema} from "mongoose";
const ArticleSchema = new Schema({
    "title": String,
    "digest": String,
    "content_source_url": String,
    "thumb_url": String,
    "thumb_media_id": String
}, {_id: false});

const AdvancedNews = new Schema({
    appID: {"type": String, "required": true},
    articles: [ArticleSchema]
}, {
    timestamps: true,
    toJSON: {
        virtuals: true,
        versionKey: false,
        transform: (doc, ret) => {
            delete ret._id
        }
    }
});

AdvancedNews.index({appID: 1});

export default model('AdvancedNews', AdvancedNews);
